package com.sunspring.jbug.common;

import lombok.Data;

/**
 * @author wulei
 * @date 2019-02-27
 **/
@Data
public class SimpleResponse {

    private int code;

    private String msg;

    private Object data;

    private SimpleResponse() {

    }

    private SimpleResponse(int code,String msg,Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private SimpleResponse(int code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    private SimpleResponse(int code, Data obj) {
        this.code = code;
        this.msg = "成功";
        this.data = obj;
    }

    /**
     * 通用成功返回,不带数据
     * @return SimpleResponse
     */
    public static SimpleResponse success() {
        return new SimpleResponse(1,"成功");
    }

    /**
     * 成功，带数据
     * @return SimpleResponse
     */
    public static SimpleResponse success(Object data) {
        return new SimpleResponse(1,"成功",data);
    }


    public static SimpleResponse error(String message) {
        return new SimpleResponse(0,message);
    }
}
